package th;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/24 10:45
 * @description 线程(用户线程和守护线程)守护
 */
public class ThreadDaemon {

    public static void main(String[] args) {

        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);

        // 默认为用户线程(true)
        thread.setDaemon(true);

        thread.start();
        new Thread(you).start();
    }

}

class God implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("god daemon you");
        }
    }
}


class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("your life is very happy");
        }
        System.out.println("==> good bye, world <==");
    }
}